package com.lemon.blog.web.service.impl;

import java.util.List;

import cn.hutool.core.util.StrUtil;
import com.lemon.common.core.constant.Constants;
import com.lemon.common.core.exception.ServiceException;
import com.lemon.common.security.utils.OptEntityUtils;
import com.lemon.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lemon.common.security.service.BaseServiceImpl;
import com.lemon.blog.web.mapper.BiFeedbackMapper;
import com.lemon.blog.web.domain.BiFeedback;
import com.lemon.blog.web.service.IBiFeedbackService;

/**
 * 包名称：com.lemon.system.service.impl
 * 类名称：BiFeedbackServiceImpl
 * 类描述：用户反馈Service业务层处理
 * 创建人：@author lemon
 * 创建时间：2023-09-14
 */
@Service
public class BiFeedbackServiceImpl extends BaseServiceImpl<BiFeedback> implements IBiFeedbackService {

    @Autowired
    private BiFeedbackMapper biFeedbackMapper;

    @Override
    public List<BiFeedback> selectBiFeedbackList(BiFeedback biFeedback) {
        return biFeedbackMapper.selectBiFeedbackList(biFeedback);
    }

    @Override
    public int insert(BiFeedback model) {
        Long currUserId = null;
        if (StrUtil.isNotEmpty(SecurityUtils.getUsername())) {
            currUserId = SecurityUtils.getLoginUser().getUserid();
        }
        if (currUserId == null) {
            throw new ServiceException("请先登录");
        }
        model.setUserId(currUserId);
        model.setStatus(Constants.STR_ZERO);
        OptEntityUtils.preInsert(model);
        return biFeedbackMapper.insertSelective(model);
    }
}
